package com.spring.springboot;

import com.spring.springboot.entity.Test;
import com.spring.springboot.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class HelloControler {
    @RequestMapping("/hello")
    public String hello(){
        return  name+"---"+":Hello EveryOne"+author.getNames()+"---"+author.getCsdnUrl();
    }

    private Author author;
    private TestService testService;
    @Autowired
    public void setAuthor(Author author){
        this.author=author;
    }
    @Autowired
    public void setTestService(TestService testService){
        this.testService=testService;
    }

    @Value("${name}")
    private String name;

    @RequestMapping("/list")
    public String getTestList(){
        List<Test> list = testService.getTestList();
        String id= "";
        for (Test tes:list) {
            id=tes.getId().toString();
        }
        return  id;
    }








}
